package com.songlanyun.modules.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.modules.coupon.entity.CouponEntity;
import com.songlanyun.modules.coupon.entity.CouponShopEntity;
import com.songlanyun.modules.goods.model.vo.GoodsSuperSlimVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.coupon.dao.CouponGoodsDao;
import com.songlanyun.modules.coupon.entity.CouponGoodsEntity;
import com.songlanyun.modules.coupon.service.CouponGoodsService;


@Service("couponGoodsService")
public class CouponGoodsServiceImpl extends ServiceImpl<CouponGoodsDao, CouponGoodsEntity> implements CouponGoodsService {

    @Override
    public CouponGoodsEntity create(CouponGoodsEntity entity) {
        return null;
    }

    @Override
    public CouponGoodsEntity modify(CouponGoodsEntity entity) {
        return null;
    }

    @Override
    public void remove(Long id) {

    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CouponGoodsEntity> page = this.page(
                new Query<CouponGoodsEntity>().getPage(params),
                new QueryWrapper<CouponGoodsEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<GoodsSuperSlimVo> loadAdaptGoods(Long shopId,Long couponId) {
        return this.baseMapper.loadAdaptGoods(shopId,couponId);
    }

    @Override
    public List<Long> loadAdaptGoodIds(Long shopId, Long couponId) {
        return this.baseMapper.loadAdaptGoodIds(shopId,couponId);
    }

    @Override
    public void batchSet(CouponEntity couponEntity, List<CouponGoodsEntity> couponGoodsEntities) {
        this.baseMapper.delete(new LambdaQueryWrapper<CouponGoodsEntity>().eq(CouponGoodsEntity::getCouponId,couponEntity.getId()));
        this.saveBatch(couponGoodsEntities);
    }



}
